home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / EVENT.DMO < prev    next >
Text File  |  1996-07-04  |  6KB  |  161 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   EVENT   .DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. $INCLUDE "KEYCODES.INC"
  19. $INCLUDE "DAS-NB01.INC"
  20. $INCLUDE "DAS-NB02.INC"
  21.  
  22. COLOR 7, 0
  23. CLS
  24. IF fMouseSETUP?( 0 ) = 0 THEN
  25.   PRINT "GOTTA HAVE A MOUSE!"
  26.   END
  27. END IF
  28. EventSETUP 5, 100
  29. GOSUB TESTSCREEN
  30. ' ──────────────────────────────────────────────────────────────────────
  31. fEventOpenT E1?(0,0), 3                            ' simulate two previously
  32. fEventOpenT E2?(0,0), 3                            ' opened events #1 and #2
  33. ' ──────────────────────────────────────────────────────────────────────
  34. MyEvent% = fEventOpenT%( E3?(0,0), 3 )             ' open "active" event
  35.  
  36. EventClear                                         ' clear kbrd & mouse keys
  37. MouseONnow                                         ' turn on the mouse
  38. Hit% = 1                                           ' 1st box (left most)
  39.                                                    '
  40. DO                                                 ' action loop
  41.   H% = ABS( Hit% )                                 '  old "hot" button
  42.   A? = 15 : GOSUB TBOXM                            '  turn "on" hot button
  43.   G% = fEventKey%( Hit%, "" )                      '  await/get action
  44.   A? = 7  : GOSUB TBOXM                            '  turn "off" hot button
  45.   IF Hit% > 0 THEN EXIT LOOP                       '  BINGO! mouse clicked
  46.   IF Hit% < 0 THEN ITERATE                         '  MOUSE is down (hot)
  47.   Hit% = H%                                        '  reset original value
  48.   SELECT CASE G%                                   '  a key-press
  49.     CASE %ENTER_key   : EXIT LOOP                  '  ENTER  - Accept HOT
  50.     CASE %ESC_key     : EXIT LOOP                  '  ESC    - Bail out
  51.     CASE %MOUSE_DOWN  :                            '  Another event is HOT
  52.     CASE %MOUSE_CLICK : BEEP                       '  Another event was HIT
  53.     CASE ELSE                                      '  any other key advances
  54.       INCR Hit%, 1                                 '   the "hot" box
  55.       IF Hit% > 3 THEN Hit% = 1                    '
  56.   END SELECT                                       '
  57. LOOP                                               '
  58. EventClose                                         ' we now close our event
  59.                                                    ' and would exit the sub
  60.                                                    ' back to the calling
  61.                                                    ' routine who's event
  62. MouseOFF                                           ' is still in running
  63. CLS                                                '
  64. END                                                '
  65.  
  66. TBOXM:
  67.   MouseCoffT E3?(0,H%),E3?(1,H%),E3?(2,H%),E3?(3,H%)  ' hot button ON/OFF
  68.   TBOX E3?(0,H%),E3?(1,H%),E3?(2,H%),E3?(3,H%),A?     ' hot button ON/OFF
  69.   MouseON                                             '
  70. RETURN
  71.  
  72. ' ──────────────────────────────────────────────────────────────────────────
  73.  
  74. FUNCTION fGetKey% () LOCAL PUBLIC
  75.  
  76.   DO
  77.     IF INSTAT THEN
  78.       FUNCTION = CVI( INKEY$ + CHR$(0) )
  79.       EXIT FUNCTION
  80.     END IF
  81.   LOOP UNTIL fMouseGetKey% <> 0
  82.   B% = fMouseStatsT%( Row?, Col? )
  83.   LOCATE 24, 1 : PRINT USING "Button: ##  Row: ##  Col: ##"; B%, Row?, Col?
  84.  
  85. END FUNCTION
  86.  
  87. ' ──────────────────────────────────────────────────────────────────────────
  88.  
  89. SUB TBOX( BYVAL Row?, BYVAL Col?, BYVAL Row2?, BYVAL Col2?, BYVAL Colour? ) LOCAL PUBLIC
  90.   LOCAL R?, Cols?
  91.  
  92.   Cols? = Col2? - Col? + 1
  93.   COLOR Colour?
  94.   FOR R? = Row? TO Row2?
  95.     LOCATE R?, Col?
  96.     PRINT STRING$( Cols?, 219 )
  97.     INCR Row?, 1
  98.   NEXT
  99.  
  100. END SUB
  101.  
  102. ' ──────────────────────────────────────────────────────────────────────────
  103. ' ─────────────   LOCAL STUFF  ─────────────────────────────────────────────
  104. ' ──────────────────────────────────────────────────────────────────────────
  105. TESTSCREEN:
  106.  
  107.   RESTORE EVENTDEMO
  108.   DIM E1?(3,3)
  109.   A? = 1
  110.   FOR B? = 0 TO 3
  111.     FOR E? = 0 TO 3
  112.       READ E1?(E?,B?)
  113.     NEXT
  114.     TBOX E1?(0,B?), E1?(1,B?), E1?(2,B?), E1?(3,B?), A?
  115.     A? = 7
  116.   NEXT
  117.  
  118.   DIM E2?(3,3)
  119.   A? = 3
  120.   FOR B? = 0 TO 3
  121.     FOR E? = 0 TO 3
  122.       READ E2?(E?,B?)
  123.     NEXT
  124.     TBOX E2?(0,B?), E2?(1,B?), E2?(2,B?), E2?(3,B?), A?
  125.     A? = 0
  126.   NEXT
  127.  
  128.   DIM E3?(3,3)
  129.   A? = 4
  130.   FOR B? = 0 TO 3
  131.     FOR E? = 0 TO 3
  132.       READ E3?(E?,B?)
  133.     NEXT
  134.     TBOX E3?(0,B?), E3?(1,B?), E3?(2,B?), E3?(3,B?), A?
  135.     A? = 7
  136.   NEXT
  137.  
  138.   COLOR 15, 0
  139.   LOCATE 1, 60 : PRINT "EVENT #1 - BLUE"
  140.   LOCATE 2, 60 : PRINT "EVENT #2 - CYAN"
  141.   LOCATE 3, 60 : PRINT "EVENT #3 - RED"
  142.  
  143. RETURN
  144.  
  145. EVENTDEMO:
  146.   'EVENT BOX 1 (BLUE)
  147.     DATA 03, 03, 08, 41
  148.     DATA 05, 05, 06, 15
  149.     DATA 05, 17, 06, 27
  150.     DATA 05, 29, 06, 39
  151.   'EVENT BOX 2 (CYAN)
  152.     DATA 10, 03, 15, 41
  153.     DATA 12, 05, 13, 15
  154.     DATA 12, 17, 13, 27
  155.     DATA 12, 29, 13, 39
  156.   'EVENT BOX 3 (RED)
  157.     DATA 12, 38, 17, 76
  158.     DATA 14, 40, 15, 50
  159.     DATA 14, 52, 15, 62
  160.     DATA 14, 64, 15, 74
  161.